package bbdd;
import java.sql.*;

public class BDProveedor {
	private static Statement s;
	private static Connection c;
	private static ResultSet reg;
	
	public static String buscarProveedor(String nom, BaseDatos bbdd){
		String cadena="SELECT cod_proveedor FROM proveedor WHERE nombre='"+nom+"'";
		bbdd.abrir();
		try{
			c=bbdd.getConexion();	
			s=c.createStatement();
			reg=s.executeQuery(cadena);
			if ( reg.next()){
				String d=reg.getString(1);
				s.close();
				bbdd.cerrar();
				return d;
			}
			s.close();
			bbdd.cerrar();
			return "";
		}
		catch ( SQLException e){
			bbdd.cerrar();
			return null;			
		}		
	}
}
